#pragma once
#include "Object.h"
#include "Resource.h"
#include "GraphicsDefs.h"
#include <memory>

class ProgramState;
class Texture2D;
struct Pass
{
public:
	Pass() {
		memset(textures, 0, sizeof(void*) * MAX_TEXTURE_UNITS);
	}
	unsigned passIdx;
	std::shared_ptr<ProgramState> programState;
	unsigned blend;
	bool depthwrite;
	unsigned depthtest;
	unsigned cullMode;
	unsigned fillMode;
	std::shared_ptr<Texture2D> textures[MAX_TEXTURE_UNITS]{};
	void Release();
};

class Context;
class  Material : public Resource
{
public:
	Material(Context* context);
	virtual ~Material();

	virtual bool BeginLoad(File& file);
	virtual bool EndLoad();

	void AddPass(const Pass& pass);
	std::vector<Pass>& GetAllPass() { return pass_; }
private:
	std::vector<Pass> pass_{};
};

